import { DataTypes } from 'sequelize';
import { Migration } from '../umzug';

/**
 * 模板表
 * @param param0 templates
 */
export const up: Migration = async ({ context: sequelize }) => {
  await sequelize.getQueryInterface().createTable('templates', {
    id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
    uuid: { type: DataTypes.STRING(36), unique: true },
    /** 问卷标题*/
    title: { type: DataTypes.STRING(100) },
    /** 问卷描述*/
    description: { type: DataTypes.TEXT },
    epilog: { type: DataTypes.TEXT }, // 问卷结语
    prefixion: { type: DataTypes.STRING(100) }, // 问卷编号开头
    logo: { type: DataTypes.STRING(255) }, // 问卷图标
    created_at: { type: DataTypes.DATE },
    updated_at: { type: DataTypes.DATE },
  });
};

export const down: Migration = async ({ context: sequelize }) => {
  await sequelize.getQueryInterface().dropTable('templates');
};
